--
-- 03/06/2012
-- demouc_m && dourle_a
--

c = {}

--- Some C types (strings)
-- @class table
-- @name types
c.types = {
   --Standart C types
   "void",
   "int",
   "char",
   "float",
   "double",
   "unsigned",
   -- LINUX
   "fd_set",
   "time_t",
   "timeval",
   "ssize_t",
   "size_t",
   --SDL types
   "SDL_Surface",
   "SDL_Event",
   "SDL_Rect",
   --FMOD
   "FMOD_SYSTEM",
   "FMOD_RESULT",
   "FMOD_INITFLAGS",
   "FMOD_SOUND"
}

--- Some C functions (strings)
-- @class table
-- @name qualifiers
c.functions = {
   "SDL_Init", -- Initializes SDL
   "SDL_InitSubSystem", -- Initialize subsystems
   "SDL_QuitSubSystem", -- Shut down a subsystem
   "SDL_Quit", -- Shut down SDL
   "SDL_WasInit", -- Check which subsystems are initialized
   "SDL_GetError", -- Get SDL error string
   "SDL_envvars", -- SDL environment variables
   "SDL_GetVideoSurface", -- returns a pointer to the current display surface
   "SDL_GetVideoInfo", -- returns a pointer to information about the video hardware
   "SDL_VideoDriverName", -- Obtain the name of the video driver
   "SDL_ListModes", -- Returns a pointer to an array of available screen dimensions for the given format and video flags
   "SDL_VideoModeOK", -- Check to see if a particular video mode is supported.
   "SDL_SetVideoMode", -- Set up a video mode with the specified width, height and bits-per-pixel.
   "SDL_UpdateRect", -- Makes sure the given area is updated on the given screen.
   "SDL_UpdateRects", -- Makes sure the given list of rectangles is updated on the given screen.
   "SDL_Flip", -- Swaps screen buffers
   "SDL_SetColors", -- Sets a portion of the colormap for the given 8-bit surface.
   "SDL_SetPalette", -- Sets the colors in the palette of an 8-bit surface.
   "SDL_SetGamma", -- Sets the color gamma function for the display
   "SDL_GetGammaRamp", -- Gets the color gamma lookup tables for the display
   "SDL_SetGammaRamp", -- Sets the color gamma lookup tables for the display
   "SDL_MapRGB", -- Map a RGB color value to a pixel format.
   "SDL_MapRGBA", -- Map a RGBA color value to a pixel format.
   "SDL_GetRGB", -- Get RGB values from a pixel in the specified pixel format.
   "SDL_GetRGBA", -- Get RGBA values from a pixel in the specified pixel format.
   "SDL_CreateRGBSurface", -- Create an empty "SDL_Surface
   "SDL_CreateRGBSurfaceFrom", -- Create an "SDL_Surface from pixel data
   "SDL_FreeSurface", -- Frees (deletes) a "SDL_Surface
   "SDL_LockSurface", -- Lock a surface for directly access.
   "SDL_UnlockSurface", -- Unlocks a previously locked surface.
   "SDL_LoadBMP", -- Load a Windows BMP file into an "SDL_Surface.
   "SDL_SaveBMP", -- Save an "SDL_Surface as a Windows BMP file.
   "SDL_SetColorKey", -- Sets the color key (transparent pixel) in a blittable surface and RLE acceleration.
   "SDL_SetAlpha", -- Adjust the alpha properties of a surface
   "SDL_SetClipRect", -- Sets the clipping rectangle for a surface.
   "SDL_GetClipRect", -- Gets the clipping rectangle for a surface.
   "SDL_ConvertSurface", -- Converts a surface to the same format as another surface.
   "SDL_BlitSurface", -- This performs a fast blit from the source surface to the destination surface.
   "SDL_FillRect", -- This function performs a fast fill of the given rectangle with some color
   "SDL_DisplayFormat", -- Convert a surface to the display format
   "SDL_DisplayFormatAlpha", -- Convert a surface to the display format
   "SDL_WarpMouse", -- Set the position of the mouse cursor.
   "SDL_CreateCursor", -- Creates a new mouse cursor.
   "SDL_FreeCursor", -- Frees a cursor created with "SDL_CreateCursor.
   "SDL_SetCursor", -- Set the currently active mouse cursor.
   "SDL_GetCursor", -- Get the currently active mouse cursor.
   "SDL_ShowCursor", -- Toggle whether or not the cursor is shown on the screen.
   "SDL_GL_LoadLibrary", -- Specify an OpenGL library
   "SDL_GL_GetProcAddress", -- Get the address of a GL function
   "SDL_GL_GetAttribute", -- Get the value of a special SDL/OpenGL attribute
   "SDL_GL_SetAttribute", -- Set a special SDL/OpenGL attribute
   "SDL_GL_SwapBuffers", -- Swap OpenGL framebuffers/Update Display
   "SDL_CreateYUVOverlay", -- Create a YUV video overlay
   "SDL_LockYUVOverlay", -- Lock an overlay
   "SDL_UnlockYUVOverlay", -- Unlock an overlay
   "SDL_DisplayYUVOverlay", -- Blit the overlay to the display
   "SDL_FreeYUVOverlay", -- Free a YUV video overlay
   "SDL_GLattr", -- SDL GL Attributes
   "SDL_Rect", -- Defines a rectangular area
   "SDL_Color", -- Format independent color description
   "SDL_Palette", -- Color palette for 8-bit pixel formats
   "SDL_PixelFormat", -- Stores surface format information
   "SDL_Surface", -- Graphical Surface Structure
   "SDL_VideoInfo", -- Video Target information
   "SDL_Overlay", -- YUV video overlay
   "SDL_WM_SetCaption", -- Sets the window tile and icon name.
   "SDL_WM_GetCaption", -- Gets the window title and icon name.
   "SDL_WM_SetIcon", -- Sets the icon for the display window.
   "SDL_WM_IconifyWindow", -- Iconify/Minimise the window
   "SDL_WM_ToggleFullScreen", -- Toggles fullscreen mode
   "SDL_WM_GrabInput", -- Grabs mouse and keyboard input.
   "SDL_ActiveEvent", -- Application visibility event structure
   "SDL_KeyboardEvent", -- Keyboard event structure
   "SDL_MouseMotionEvent", -- Mouse motion event structure
   "SDL_MouseButtonEvent", -- Mouse button event structure
   "SDL_JoyAxisEvent", -- Joystick axis motion event structure
   "SDL_JoyButtonEvent", -- Joystick button event structure
   "SDL_JoyHatEvent", -- Joystick hat position change event structure
   "SDL_JoyBallEvent", -- Joystick trackball motion event structure
   "SDL_ResizeEvent", -- Window resize event structure
   "SDL_ExposeEvent", -- Quit requested event
   "SDL_SysWMEvent", -- Platform-dependent window manager event.
   "SDL_UserEvent", -- A user-defined event type
   "SDL_QuitEvent", -- Quit requested event
   "SDL_keysym", -- Keysym structure
   "SDL_PumpEvents", -- Pumps the event loop, gathering events from the input devices.
   "SDL_PeepEvents", -- Checks the event queue for messages and optionally returns them.
   "SDL_PollEvent", -- Polls for currently pending events.
   "SDL_WaitEvent", -- Waits indefinitely for the next available event.
   "SDL_PushEvent", -- Pushes an event onto the event queue
   "SDL_SetEventFilter", -- Sets up a filter to process all events before they are posted to the event queue.
   "SDL_GetEventFilter", -- Retrieves a pointer to he event filter
   "SDL_EventState", -- This function allows you to set the state of processing certain events.
   "SDL_GetKeyState", -- Get a snapshot of the current keyboard state
   "SDL_GetModState", -- Get the state of modifier keys.
   "SDL_SetModState", -- Set the current key modifier state
   "SDL_GetKeyName", -- Get the name of an SDL virtual keysym
   "SDL_EnableUNICODE", -- Enable UNICODE translation
   "SDL_EnableKeyRepeat", -- Set keyboard repeat rate.
   "SDL_GetMouseState", -- Retrieve the current state of the mouse
   "SDL_GetRelativeMouseState", -- Retrieve the current state of the mouse
   "SDL_GetAppState", -- Get the state of the application
   "SDL_JoystickEventState", -- Enable/disable joystick event polling
   "SDL_NumJoysticks", -- Count available joysticks.
   "SDL_JoystickName", -- Get joystick name.
   "SDL_JoystickOpen", -- Opens a joystick for use.
   "SDL_JoystickOpened", -- Determine if a joystick has been opened
   "SDL_JoystickIndex", -- Get the index of an "SDL_Joystick.
   "SDL_JoystickNumAxes", -- Get the number of joystick axes
   "SDL_JoystickNumBalls", -- Get the number of joystick trackballs
   "SDL_JoystickNumHats", -- Get the number of joystick hats
   "SDL_JoystickNumButtons", -- Get the number of joysitck buttons
   "SDL_JoystickUpdate", -- Updates the state of all joysticks
   "SDL_JoystickGetAxis", -- Get the current state of an axis
   "SDL_JoystickGetHat", -- Get the current state of a joystick hat
   "SDL_JoystickGetButton", -- Get the current state of a given button on a given joystick
   "SDL_JoystickGetBall", -- Get relative trackball motion
   "SDL_JoystickClose", -- Closes a previously opened joystick
   "SDL_AudioSpec", -- Audio Specification Structure
   "SDL_OpenAudio", -- Opens the audio device with the desired parameters.
   "SDL_PauseAudio", -- Pauses and unpauses the audio callback processing
   "SDL_GetAudioStatus", -- Get the current audio state
   "SDL_LoadWAV", -- Load a WAVE file
   "SDL_FreeWAV", -- Frees previously opened WAV data
   "SDL_AudioCVT", -- Audio Conversion Structure
   "SDL_BuildAudioCVT", -- Initializes a "SDL_AudioCVT structure for conversion
   "SDL_ConvertAudio", -- Convert audio data to a desired audio format.
   "SDL_MixAudio", -- Mix audio data
   "SDL_LockAudio", -- Lock out the callback function
   "SDL_UnlockAudio", -- Unlock the callback function
   "SDL_CloseAudio", -- Shuts down audio processing and closes the audio device.
   "SDL_CDNumDrives", -- Returns the number of CD-ROM drives on the system.
   "SDL_CDName", -- Returns a human-readable, system-dependent identifier for the CD-ROM.
   "SDL_CDOpen", -- Opens a CD-ROM drive for access.
   "SDL_CDStatus", -- Returns the current status of the given drive.
   "SDL_CDPlay", -- Play a CD
   "SDL_CDPlayTracks", -- Play the given CD track(s)
   "SDL_CDPause", -- Pauses a CDROM
   "SDL_CDResume", -- Resumes a CDROM
   "SDL_CDStop", -- Stops a CDROM
   "SDL_CDEject", -- Ejects a CDROM
   "SDL_CDClose", -- Closes a "SDL_CD handle
   "SDL_CD", -- CDROM Drive Information
   "SDL_CDtrack", -- CD Track Information Structure
   "SDL_CreateThread", -- Creates a new thread of execution that shares its parent's properties.
   "SDL_ThreadID", -- Get the 32-bit thread identifier for the current thread.
   "SDL_GetThreadID", -- Get the SDL thread ID of a "SDL_Thread
   "SDL_WaitThread", -- Wait for a thread to finish.
   "SDL_KillThread", -- Gracelessly terminates the thread.
   "SDL_CreateMutex", -- Create a mutex
   "SDL_DestroyMutex", -- Destroy a mutex
   "SDL_mutexP", -- Lock a mutex
   "SDL_mutexV", -- Unlock a mutex
   "SDL_CreateSemaphore", -- Creates a new semaphore and assigns an initial value to it.
   "SDL_DestroySemaphore", -- Destroys a semaphore that was created by "SDL_CreateSemaphore.
   "SDL_SemWait", -- Lock a semaphore and suspend the thread if the semaphore value is zero.
   "SDL_SemTryWait", -- Attempt to lock a semaphore but don't suspend the thread.
   "SDL_SemWaitTimeout", -- Lock a semaphore, but only wait up to a specified maximum time.
   "SDL_SemPost", -- Unlock a semaphore.
   "SDL_SemValue", -- Return the current value of a semaphore.
   "SDL_CreateCond", -- Create a condition variable
   "SDL_DestroyCond", -- Destroy a condition variable
   "SDL_CondSignal", -- Restart a thread wait on a condition variable
   "SDL_CondBroadcast", -- Restart all threads waiting on a condition variable
   "SDL_CondWait", -- Wait on a condition variable
   "SDL_CondWaitTimeout", -- Wait on a condition variable, with timeout
   "SDL_GetTicks", -- Get the number of milliseconds since the SDL library initialization.
   "SDL_Delay", -- Wait a specified number of milliseconds before returning.
   "SDL_AddTimer", -- Add a timer which will call a callback after the specified number of milliseconds has elapsed.
   "SDL_RemoveTimer", -- Remove a timer which was added with "SDL_AddTimer.
   "SDL_SetTimer" -- Set a callback to run after the specified number of milliseconds has elapsed.
}

--- Default C qualifiers (strings)
-- @class table
-- @name qualifiers
c.qualifier = {
   "const",
   "extern",
   "inline",
   "long",
   "short",
   "signed",
   "static",
   "struct",
   "unsigned",
   "volatile"
}

c.static = "static"

--- Check if the text is a valid c type
-- @param token to check
-- @return boolean
function c.isType(text)
   for i,v in ipairs(c.types) do
      if v == text then return true end
   end
   return false
end

--- Check if the text is a valid c qualifier
-- @param token to check
-- @return boolean
function c.isQualifier(text)
   for i,v in ipairs(c.qualifier) do
      if v == text then return true end
   end
   return false
end